// 获取数据渲染
var product=document.querySelector("#product");
var ulbox=document.querySelector("#ulbox");
var dianji=document.querySelector(".dianji");

let xhr1=new XMLHttpRequest();
xhr1.open("get","http://chst.vip:1234/api/getinlanddiscount",false);
xhr1.onload=function(){
let lis1="";
if(xhr1.status===200){
let res1=JSON.parse(xhr1.responseText);
console.log(res1.result);
res1.result.forEach(element => {
                    console.log(element);
 lis1+=`
                    <li id="${element.productId}">
                                        <div class="img" >
                                        ${element.productImg}
                                        </div>
                                        <div class="title">
                                        ${element.productName}
                                        </div>
                                        <p class="price">
                                        ${element.productPrice}
                                        </p>
                                        <p class="from">
                                        ${element.productFrom} |${element.productTime}
                                        </p>
                    
                    </li>
                    ` 
});
ulbox.innerHTML=lis1;
}}
xhr1.send();

// 点击跳转事件

ulbox.onclick=function(e){
                    var e= e||window.event;
                    var target=e.target || e.srcElement;

                    if(target.nodeName==="DIV" ||target.nodeName==="P"){
                                    proId=target.parentNode.id;    
                    }else if(target.nodeName==="IMG"){
                                        proId=target.parentNode.parentNode.id     
                    }else if(target.nodeName==="LI"){
                                        proId=target.id;       
                    }
                    window.location.href="../html/koudetail.html?productid="+proId;
}
